package com.book.service.impl;

import com.book.entity.Role;
import com.book.mapper.RoleMapper;
import com.book.service.RoleService;
import com.book.vo.MenuVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author SuperYu  2024/6/26
 */
@Service
public class RoleServiceImpl implements RoleService {
    RoleMapper roleMapper;

    @Autowired
    public void setRoleMapper(RoleMapper roleMapper) {
        this.roleMapper = roleMapper;
    }


    RedisTemplate<String, Object> redisTemplate;

    @Autowired
    public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }


    @Override
    @Cacheable(value="role", key="#root.methodName+#root.args[0]")
    public List<Role> findRoleByUserName(String name) {
        return null;
    }


    @Override
    @Cacheable(value="role", key="#root.methodName+#root.args[0]+#root.args[1]")
    public PageInfo<Role> findAllRole(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Role> list = roleMapper.selectAll();
        return new PageInfo<>(list);
    }

}







